<template>
  <div>
    我是列表页
    <div>
      <router-link to="/detail" replace> 跳转到详情页 replace</router-link> <br />
      <router-link :to="{ path: '/detail', query: { a: 1, b: 2, c: true, d: [1, 2, 3] } }">
        跳转到详情页 携带参数
      </router-link>
    </div>
    <hr />
    <button @click="go2deatilByPush">编程式导航跳转到 detail页面 push</button>
    <button @click="go2deatilByReplace">编程式导航跳转到 detail页面 replace</button>
  </div>
</template>
<script setup>
import { useRouter } from 'vue-router';

//  通过useRouter得到router等同于配置api当中的 this.$router
const router = useRouter();

const go2deatilByPush = () => {
  router.push({ path: '/detail', query: { id: 3 } });
};

const go2deatilByReplace = () => {
  router.replace('/detail');
};
</script>
